#ifndef __ECONOMY_HOME_H__
#define __ECONOMY_HOME_H__

#include <map>
#include <mutex>
#include "GameSingleton.h"
#include "Engine/GameGuid.h"
#include "Expand/IPlugin.h"
#include "Engine/Point3.hpp"

namespace PocketSurvival
{
    class GameManager;
}

using namespace PocketSurvival;
using namespace PocketSurvival::Engine;

namespace Economy
{
    class EconomyAPI;

    class EconomyHome : public SimpleSingletonItem
    {
        friend class PocketSurvival::SimpleSingleton;
    private:
        GameManager *m_gameManager;
        EconomyAPI *m_economyAPI;

        std::map<GameGuid, Point3> m_homeMap;
        std::mutex m_homeMapMutex;

        // 使用回家所需的钱
        uint32_t m_useMoney;

    private:
        EconomyHome() = default;
        ~EconomyHome();
        EconomyHome(const EconomyHome &) = delete;
        EconomyHome(EconomyHome &&) = delete;
        EconomyHome &operator=(const EconomyHome &) = delete;
        EconomyHome &operator=(EconomyHome &&) = delete;

    public:
        void load();
        void save();

        void setGuidHome(const GameGuid &guid, const Point3 &point);
        bool getGuidHome(const GameGuid &guid, Point3 &outPoint);
        void processCmd(IPlugin::ChatObj &chatObj, std::vector<std::string> &cmdDataVec);

    };
    
} // namespace Economy

#endif
